package action;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pojo.College;
import pojo.Message;
import service.BackCollegeService;
import service.BackMessageService;
import serviceImpl.BackCollegeServiceImpl;
import serviceImpl.BackMessageServiceImpl;


@WebServlet("/BackMessageServlet")
public class BackMessageServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public BackMessageServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		String mark = request.getParameter("mark");
		switch(mark) {
		
		case "showMessage": 
			showMessage(request,response);
			break;
		
		
		}
	}
	
	private void showMessage(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		BackMessageService bms = new BackMessageServiceImpl();
		ArrayList<Message> mList = new ArrayList<Message>();
		mList = bms.getMessage();
		request.setAttribute("messageList", mList);
		request.getRequestDispatcher("/background/ordUserJs/index/message.jsp").forward(request, response);
		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
